package com.baitengsoft.patentapimonitor.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * cors 跨域
 * @author wangze
 * @date 2017-12-15 13:20.
 **/
@Configuration
public class CorsWebAppConfigurer extends WebMvcConfigurerAdapter {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
                .allowedHeaders("content-type", "x-requested-with", "accept", "origin", "access-control-request-method",
                       "access-control-request-headers","api_key")
                .allowCredentials(true);
    }
}